import 'package:love_newf/generated/json/base/json_convert_content.dart';
import 'package:love_newf/app/com/model/room_type_model.dart';

RoomTypeModel $RoomTypeModelFromJson(Map<String, dynamic> json) {
  final RoomTypeModel roomTypeModel = RoomTypeModel();
  final int? roomType = jsonConvert.convert<int>(json['roomType']);
  if (roomType != null) {
    roomTypeModel.roomType = roomType;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    roomTypeModel.name = name;
  }
  final int? roomPeople = jsonConvert.convert<int>(json['roomPeople']);
  if (roomPeople != null) {
    roomTypeModel.roomPeople = roomPeople;
  }
  final int? needBuy = jsonConvert.convert<int>(json['needBuy']);
  if (needBuy != null) {
    roomTypeModel.needBuy = needBuy;
  }
  final List<
      RoomTypeRoomAuthPrices>? roomAuthPrices = (json['roomAuthPrices'] as List<
      dynamic>?)
      ?.map(
          (e) =>
      jsonConvert.convert<RoomTypeRoomAuthPrices>(e) as RoomTypeRoomAuthPrices)
      .toList();
  if (roomAuthPrices != null) {
    roomTypeModel.roomAuthPrices = roomAuthPrices;
  }
  final String? expireTime = jsonConvert.convert<String>(json['expireTime']);
  if (expireTime != null) {
    roomTypeModel.expireTime = expireTime;
  }
  return roomTypeModel;
}

Map<String, dynamic> $RoomTypeModelToJson(RoomTypeModel entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['roomType'] = entity.roomType;
  data['name'] = entity.name;
  data['roomPeople'] = entity.roomPeople;
  data['needBuy'] = entity.needBuy;
  data['roomAuthPrices'] =
      entity.roomAuthPrices.map((v) => v.toJson()).toList();
  data['expireTime'] = entity.expireTime;
  return data;
}

extension RoomTypeModelExtension on RoomTypeModel {
  RoomTypeModel copyWith({
    int? roomType,
    String? name,
    int? roomPeople,
    int? needBuy,
    List<RoomTypeRoomAuthPrices>? roomAuthPrices,
    String? expireTime,
  }) {
    return RoomTypeModel()
      ..roomType = roomType ?? this.roomType
      ..name = name ?? this.name
      ..roomPeople = roomPeople ?? this.roomPeople
      ..needBuy = needBuy ?? this.needBuy
      ..roomAuthPrices = roomAuthPrices ?? this.roomAuthPrices
      ..expireTime = expireTime ?? this.expireTime;
  }
}

RoomTypeRoomAuthPrices $RoomTypeRoomAuthPricesFromJson(
    Map<String, dynamic> json) {
  final RoomTypeRoomAuthPrices roomTypeRoomAuthPrices = RoomTypeRoomAuthPrices();
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    roomTypeRoomAuthPrices.id = id;
  }
  final int? roomType = jsonConvert.convert<int>(json['roomType']);
  if (roomType != null) {
    roomTypeRoomAuthPrices.roomType = roomType;
  }
  final String? title = jsonConvert.convert<String>(json['title']);
  if (title != null) {
    roomTypeRoomAuthPrices.title = title;
  }
  final int? price = jsonConvert.convert<int>(json['price']);
  if (price != null) {
    roomTypeRoomAuthPrices.price = price;
  }
  final int? day = jsonConvert.convert<int>(json['day']);
  if (day != null) {
    roomTypeRoomAuthPrices.day = day;
  }
  return roomTypeRoomAuthPrices;
}

Map<String, dynamic> $RoomTypeRoomAuthPricesToJson(
    RoomTypeRoomAuthPrices entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['roomType'] = entity.roomType;
  data['title'] = entity.title;
  data['price'] = entity.price;
  data['day'] = entity.day;
  return data;
}

extension RoomTypeRoomAuthPricesExtension on RoomTypeRoomAuthPrices {
  RoomTypeRoomAuthPrices copyWith({
    int? id,
    int? roomType,
    String? title,
    int? price,
    int? day,
  }) {
    return RoomTypeRoomAuthPrices()
      ..id = id ?? this.id
      ..roomType = roomType ?? this.roomType
      ..title = title ?? this.title
      ..price = price ?? this.price
      ..day = day ?? this.day;
  }
}